package com.doit.day02;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Table;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class _09_get数据 {
    public static void main(String[] args) throws IOException {
        Connection conn = HbaseUtil.getConn();
        Table table = conn.getTable(TableName.valueOf("doit:table_name"));

        Get get = new Get("rowkey_001".getBytes(StandardCharsets.UTF_8));
//        get.addColumn("f1".getBytes(StandardCharsets.UTF_8),"name".getBytes(StandardCharsets.UTF_8));

        Result result = table.get(get);
        //获取出来的结果有可能是空，需要先判断一下   类似于迭代器
        while (result.advance()){
            Cell current = result.current();
            //cell的工具包  克隆获取我们想要的结果
            System.out.println("行键是："+new String(CellUtil.cloneRow(current)));
            System.out.println("列族是："+new String(CellUtil.cloneFamily(current)));
            System.out.println("列是："+new String(CellUtil.cloneQualifier(current)));
            System.out.println("值是："+new String(CellUtil.cloneValue(current)));
            System.out.println("==========分割一下=============");
        }



    }
}
